package com.hntest.service.impl;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import com.hntest.dao.SystemDictionaryDao;
import com.hntest.entity.Page;
import com.hntest.entity.SystemDictionary;
import com.hntest.service.SystemDictionaryService;

/**
 * 数据字典目录业务的实现类
 * @author ZHOU
 *
 */
@Service("dictionaryService")
public class DictionaryServiceImpl implements SystemDictionaryService{

	@Autowired
	private SystemDictionaryDao dictionaryDao;
	
	//添加数据字典目录
	@Override
	public int addDictionary(String sn, String title) {
		SystemDictionary dictionary = new SystemDictionary();
		dictionary.setSn(sn);
		dictionary.setTitle(title);
		int n = dictionaryDao.addDictionary(dictionary);
		return n;
	}

	//查询所有的数据字典目录信息
	@Override
	public List<SystemDictionary> getAll() {
		List<SystemDictionary> list = dictionaryDao.getAll();
		return list;
	}

	//查询数据字典目录的总记录数
	@Override
	public int getCount() {
		int n = dictionaryDao.getCount();
		return n;
	}

	//分页查询所有数据字典目录信息
	@Override
	public List<SystemDictionary> getListByPage(Page page,SystemDictionary condition) {
		Map<String,Object> map = new HashMap<String,Object>();
		map.put("pageStart",((page.getCurrPage()-1)*page.getPageSize()+1));
        map.put("pageEnd",(page.getCurrPage()*page.getPageSize()));
        map.put("condition", condition);
        List<SystemDictionary> list = dictionaryDao.getListByPage(map);
		return list;
	}

	//删除数据字典目录对象信息
	@Override
	public int deleteDictionary(int dictionaryId) {
		int n = dictionaryDao.deletDictionary(dictionaryId);
		return n;
	}
	
}
